package com.silences.servlet;

import com.alibaba.fastjson.JSON;
import com.silences.pojo.User;
import com.silences.service.UserService;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.rmi.ServerException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

//登录退出接口
@WebServlet("/logout") //设置接口路径
public class LogoutServlet extends HttpServlet {
    //extends 继承 HttpServlet类

    //get 请求
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
       doPost(req,resp);
    }


    //post 请求
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServerException,IOException {

        //在服务器中清除用户名
        req.getSession().removeAttribute("username");
        // 使用重定向，跳转登录页面
        resp.sendRedirect("/Test/login.html");

    }
}
